<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<!-- <el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input clearable v-model="filters.date" placeholder="搜索"></el-input>
				</el-form-item>

				<el-form-item>
					<el-button type="primary" v-on:click="search">筛选</el-button>
				</el-form-item>
			</el-form> -->

		</el-col>


		<el-card class="box-card" style="width: 80%">
			<div slot="header" class="clearfix">
				<span style="line-height: 36px;">新注册数量统计</span>
				<!-- <el-button style="float: right;" type="primary">操作按钮</el-button> -->
			</div>
			<div class="text item">
			<el-radio-group v-model="card1.type">
				<el-radio class="radio" :label="1">按天</el-radio>
				<el-radio class="radio" :label="2">按月</el-radio>
			</el-radio-group>
			<el-date-picker
					v-show="card1.type==1"
					v-model="card1.stime"
					format="yyyy-MM-dd"
					@change="toTime1"
					placeholder="选择日期">
			</el-date-picker>
			<el-date-picker
					v-show="card1.type==2"
					v-model="card1.etime"
					format="yyyy-MM"
					type="month"
					@change="toTime2"
					placeholder="选择月份">
			</el-date-picker>
			<el-button type="primary" v-on:click="do1" >查询</el-button>
			{{this.card1.regNum}}

			</div>
		</el-card>


		<el-card class="box-card" style="width: 80%;margin-top: 20px">
			<div slot="header" class="clearfix">
				<span style="line-height: 36px;">总输赢统计</span>
			</div>
			<div class="item">
				<el-button type="primary" v-on:click="do2" >查询</el-button>

				<div>负盈利 : {{card2.profit}}    正亏损: {{card2.loss}}   投注量： {{card2.bet_amt}}</div>
				<!-- <el-table :data="card2" style="width: 50%;margin-top: 10px;">
					<el-table-column prop="profit" label="负盈利"></el-table-column>
					<el-table-column prop="loss" label="正亏损"></el-table-column>
					<el-table-column prop="bet_amt" label="投注量"></el-table-column>
				</el-table> -->
			</div>
		</el-card>


		<el-card class="box-card" style="width: 80%;margin-top: 20px"">
			<div slot="header" class="clearfix">
				<span style="line-height: 36px;">日输赢统计/月输赢统计</span>
			</div>
			<div class="text item">
			<el-radio-group v-model="card3.type">
				<el-radio class="radio" :label="1">按天</el-radio>
				<el-radio class="radio" :label="2">按月</el-radio>
			</el-radio-group>
			<el-date-picker
					v-show="card3.type==1"
					v-model="card3.stime"
					format="yyyy-MM-dd"
					@change="toTime3"
					placeholder="选择日期">
			</el-date-picker>
			<el-date-picker
					v-show="card3.type==2"
					v-model="card3.etime"
					format="yyyy-MM"
					type="month"
					@change="toTime4"
					placeholder="选择月份">
			</el-date-picker>
			<el-button type="primary" v-on:click="do3" >查询</el-button>
			<!-- {{this.card1.regNum}} -->

			</div>
		</el-card>
		
	</section>
</template>

<script>
	import { registerUser,allRevenue,revenue} from '../../api/api';
	import axios from 'axios';

	export default {
		data() {
			return {
				host:this.GLOBAL.host,
				current:1,
				token:'',
				userId:'',

				card1: {
					type:1,
					stime:'',
					etime:'',
					regNum:''
				},
				card2:{},
				card3: {
					type:1,
					stime:'',
					etime:'',
				},



			}
		},
		methods: {
			do1(){
				if(this.card1.type == 1 && !this.card1.stime){
					alert('请选择日期')
					return false;
				}
				if(this.card1.type == 2 && !this.card1.etime){
					alert('请选择月份')
					return false;
				}

				// axios.get("/api/TYAdmin/v1/statistics/all-revenue",
    //                 {
    //                     // 'user_name':'admin',
    //                     // 'password':'123',
    //                     // 'gg_secret_num':'admin',
    //                 },
    //                 {
    //                     headers: {},
    //                 }
    //             ).then((login)=>{

    //                 console.log(login)
    //             })

    //             return false;

				let para = {
					type:this.card1.type,
					date:this.card1.type == 1 ? this.card1.stime : this.card1.etime,
				};
				registerUser(para).then((res) => {
					let { message, code, data } = res;

					if(code != 200){
						this.$message({
							message: message?message:'请求失败',
							type: 'error'
						});
						return false;
					}

					this.card1.regNum = data;

				});

			},
			deltag(key){
				this.checkTags.splice(key,1);
			},

			do2() {
				let para = {};
				allRevenue(para).then((res) => {
					let { message, code, data } = res;
					if(code != 200){
						this.$message({
							message: message?message:'请求失败',
							type: 'error'
						});
						return false;
					}

					this.card2 = data;

				});
			},
			do3(){
				if(this.card3.type == 1 && !this.card3.stime){
					alert('请选择日期')
					return false;
				}
				if(this.card3.type == 2 && !this.card3.etime){
					alert('请选择月份')
					return false;
				}
				let para = {
					type:this.card3.type,
					date:this.card3.type == 1 ? this.card3.stime : this.card3.etime,
				};

				revenue(para).then((res) => {
					let { message, code, data } = res;

					if(code != 200){
						this.$message({
							message: message?message:'请求失败',
							type: 'error'
						});
						return false;
					}

					// this.card1.regNum = data;

				});

			},
			toTime1(date){
				this.card1.stime = date;
			},
			toTime2(date){
				this.card1.etime = date;
			},
			toTime3(date){
				this.card3.stime = date;
			},
			toTime4(date){
				this.card3.etime = date;
			},
		},

		mounted() {
			// var user = sessionStorage.getItem('user');
			// var user = localStorage.getItem('user');
			// this.getList();
		}
	}

</script>

<style scoped>
.numbers{
	color: #409EFF;
	cursor: pointer;
}

</style>
<style>
	.text {
		font-size: 14px;
	}

	.item {
		padding: 18px 0;
	}

	.clearfix:before,
	.clearfix:after {
		display: table;
		content: "";
	}
	.clearfix:after {
		clear: both
	}

	.box-card {
		width: 480px;
	}
</style>